// ==UserScript==
// @name			인택 타이머
// @author			후리니
// @version			1.0.3
// @description		파트너와 우개전 화면에서 정해진 시간이 되면 사용자에게 알려줍니다.
// @require			http://userscripts.org/scripts/source/87345.user.js
// @require			http://userscripts.org/scripts/source/98574.user.js
// @include			http://tac.astasdf.net/msvs.cgi
// @include			http://tac.astasdf.net/ps_btlview.cgi
// @include			http://kite.us.to/msvs.cgi
// @include			http://kite.us.to/ps_btlview.cgi
// ==/UserScript==
devtools.config.init({
	title: '인택 타이머 설정',
	html: '',
	settings: {
		'al_type': {
			type: 'select',
			options: {'- 팝업으로 표시 -':'0','- 사용자 지정 알림음 -':'1','01. 기본 효과음':'2','02. 윳쿠리 보이스(어그로)':'3','03. 야라나이카':'4','04. 두산이 해냈어':'5','05. 더월드':'6','06. 파이널 퓨전':'7','07. 정시 알람':'8','08. 뉴클리어':'9','09. 오와타':'10','10. 뉴타입':'11'},
			label: '알림 방법',
			defaultValue: 2
		},
		'volume': {
			type: 'text',
			label: '사용자지정 - 소리 크기',
			defaultValue: '100'
		},
		'url': {
			type: 'text',
			label: '사용자지정 - 파일주소',
			defaultValue: 'http://pds20.egloos.com/pds/201104/26/68/alarm_01.mp3'
		},
		'time': {
			type: 'text',
			label: '사용자지정 - 길이',
			defaultValue: '5'
		},
	},
});

var conf_btn = document.createElement("button");
conf_btn.className = "btn";
conf_btn.type = "button";
conf_btn.innerHTML="인택 타이머 설정";
document.body.insertBefore(conf_btn, document.body.childNodes[2]);
conf_btn.addEventListener('click', function(e) {
	e.preventDefault();
	devtools.config.open();
}, false);
	
if(typeof GM_registerMenuCommand != 'undefined')GM_registerMenuCommand('인택 타이머 - 설정', function(){devtools.config.open();});

if(document.getElementsByName("clock")[0])
{

var alarm_type = devtools.config.get('al_type');
var sound_volume = devtools.config.get('volume');

var url_list = new Array();
url_list[0] = '';
url_list[1] = devtools.config.get('url');
url_list[2] = 'http://intac-timer.googlecode.com/files/alarm_01.mp3';
url_list[3] = 'http://intac-timer.googlecode.com/files/SofTalk.mp3';
url_list[4] = 'http://intac-timer.googlecode.com/files/Mr-ya.mp3';
url_list[5] = 'http://intac-timer.googlecode.com/files/doosando.mp3';
url_list[6] = 'http://intac-timer.googlecode.com/files/the_world.mp3';
url_list[7] = 'http://intac-timer.googlecode.com/files/final_fusion.mp3';
url_list[8] = 'http://intac-timer.googlecode.com/files/news_alarm.mp3';
url_list[9] = 'http://intac-timer.googlecode.com/files/nuclear.mp3';
url_list[10] = 'http://intac-timer.googlecode.com/files/owata.mp3';
url_list[11] = 'http://intac-timer.googlecode.com/files/newtype.mp3';
var url_time = new Array();
url_time[0] = 4;
url_time[1] = Number(devtools.config.get('time'));
url_time[2] = 5;
url_time[3] = 4;
url_time[4] = 2;
url_time[5] = 8;
url_time[6] = 5;
url_time[7] = 3;
url_time[8] = 5;
url_time[9] = 3;
url_time[10] = 5;
url_time[11] = 2;

var sound_url = url_list[alarm_type];
var sound_time = url_time[alarm_type]+2;




function alarm()
{
	var alrt = document.createElement("div");
	alrt.innerHTML = "<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' width='1' height='1' id='alarm1' name='alarm1'><param name='movie' value='http://pds21.egloos.com/pds/201104/26/68/player.swf'><param name='allowfullscreen' value='true'><param name='allowscriptaccess' value='always'><param name='wmode' value='transparent'><param name='flashvars' value='duration="+ sound_time +"&file="+ sound_url +"&volume="+ sound_volume +"&autostart=true'><embed type='application/x-shockwave-flash' id='alarm2' name='alarm2' src='http://pds21.egloos.com/pds/201104/26/68/player.swf' width='1' height='1' bgcolor='undefined' allowscriptaccess='always' allowfullscreen='true' wmode='transparent' flashvars='duration="+ sound_time +"&file="+ sound_url +"&volume="+ sound_volume +"&autostart=true'/></object>";
	document.body.insertBefore(alrt, document.body.firstChild);
}

if(alarm_type==0){
setTimeout("alert('Time to Click!');",document.getElementsByName("clock")[0].value*1000-1000);
}
else{
setTimeout(alarm,document.getElementsByName("clock")[0].value*1000-(sound_time*1000));
}

}